/*    */ package com.cr.framework.shiro.service;
/*    */ 
/*    */ import com.cr.common.utils.MyStringUtils;
/*    */ import com.cr.framework.shiro.session.OnlineSession;
/*    */ import com.cr.system.domain.SysUserOnline;
/*    */ import com.cr.system.service.ISysUserOnlineService;
/*    */ import java.io.Serializable;
/*    */ import org.apache.shiro.session.Session;
/*    */ import org.springframework.beans.factory.annotation.Autowired;
/*    */ import org.springframework.stereotype.Component;
/*    */ 
/*    */ @Component
/*    */ public class SysShiroService {
/*    */   @Autowired
/*    */   private ISysUserOnlineService onlineService;
/*    */   
/*    */   public void deleteSession(OnlineSession onlineSession) {
/* 30 */     this.onlineService.deleteOnlineById(String.valueOf(onlineSession.getId()));
/*    */   }
/*    */   
/*    */   public Session getSession(Serializable sessionId) {
/* 41 */     SysUserOnline userOnline = this.onlineService.selectOnlineById(String.valueOf(sessionId));
/* 42 */     return MyStringUtils.isNull(userOnline) ? null : createSession(userOnline);
/*    */   }
/*    */   
/*    */   public Session createSession(SysUserOnline userOnline) {
/* 47 */     OnlineSession onlineSession = new OnlineSession();
/* 48 */     if (MyStringUtils.isNotNull(userOnline)) {
/* 50 */       onlineSession.setId(userOnline.getSessionId());
/* 51 */       onlineSession.setHost(userOnline.getIpaddr());
/* 52 */       onlineSession.setBrowser(userOnline.getBrowser());
/* 53 */       onlineSession.setOs(userOnline.getOs());
/* 54 */       onlineSession.setDeptName(userOnline.getDeptName());
/* 55 */       onlineSession.setLoginName(userOnline.getLoginName());
/* 56 */       onlineSession.setStartTimestamp(userOnline.getStartTimestamp());
/* 57 */       onlineSession.setLastAccessTime(userOnline.getLastAccessTime());
/* 58 */       onlineSession.setTimeout(userOnline.getExpireTime().longValue());
/*    */     } 
/* 60 */     return (Session)onlineSession;
/*    */   }
/*    */ }


/* Location:              D:\tmp\creditorRights-admin\BOOT-INF\lib\creditorRights-framework-4.7.0.jar!\com\cr\framework\shiro\service\SysShiroService.class
 * Java compiler version: 8 (52.0)
 * JD-Core Version:       1.1.3
 */